<template>
      <div class="orders">
    <my-bread :breadList="breadList"></my-bread>
     <el-card>
     <div class="top">
      <el-input   placeholder="请输入内容" v-model="getOrderFn.query" class="input-with-select cc">
      <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
     </el-input>
     </div>
        <el-table
    :data="orderData"
    border
    style="width: 100%">
    <el-table-column
      label="#"
      type="index"
      width="100">
    </el-table-column>
    <el-table-column
      prop="order_number"
      label="订单编号"
      width="120">
    </el-table-column>
     <el-table-column
      prop="order_price"
      label="订单价格"
      width="120">
    </el-table-column>
    <el-table-column
      prop="order_pay"
      label="是否付款"
      width="120">
      <template slot-scope="scope">
        <el-tag :type="scope.row.pay_status | paycolor ">{{scope.row.pay_status | pay}}</el-tag>
	</template>
    </el-table-column>
    <el-table-column
      prop="is_send"
      label="是否发货"
      width="120">
    </el-table-column>
    <el-table-column
      prop="role_name"
      label="下单时间"
      width="300">
      <template slot-scope="scope">
          <p>{{scope.row.create_time | timer1}}</p>
      </template>
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="200">
       <template>
          <el-tooltip
            class="item"
            effect="dark"
            content="修改订单地址"
            placement="top"
            @click="Edit(scope.row)"
          >
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
              @click="handleEditArea"
            ></el-button>
          </el-tooltip>

          <el-tooltip
            class="item"
            effect="dark"
            content="物流信息"
            placement="top"
          >
            <el-button
              type="success"
              icon="el-icon-location"
              size="small"
              @click="handeate"
            ></el-button>
          </el-tooltip>
        </template>
    </el-table-column>
  </el-table>
    <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="getOrderFn.pagenum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="getOrderFn.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
     </el-card>
      <!-- 编辑弹框 -->
    <el-dialog
      title="修改地址"
      :visible.sync="dialogVisible"
      width="50%"
    >
      <el-form
        ref="ruleForm"
        :rules="rules"
        :model="Editform"
        label-width="80px"
      >
        <el-form-item label="省市区/县" prop="area">
          <el-cascader
            :options="cityOptions"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="address">
          <el-input v-model="Editform.address"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="EditForm">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 物流弹框 -->
    <el-dialog title="物流信息" :visible.sync="dialogWuliu" width="35%">
      <!-- 时间线 -->
      <el-timeline :reverse="false">
        <el-timeline-item
          v-for="(activity, index) in WuLiu.data"
          :key="index"
           :icon="activity.icon"
          :color="activity.color"
          :size="activity.size"
          :timestamp="activity.time"
        >
          {{ activity.context }}
        </el-timeline-item>
      </el-timeline>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogWuliu = false">取 消</el-button>
        <el-button type="primary" @click="wuliuOk">确 定</el-button>
      </div>
    </el-dialog>
     </div>
     
</template>

<script>
import WuLiu from "@/components/wuliu/WuLiu.js";
import { getorders } from "@/http/orders.js";
import cityOptions from "@/provinces-china-master/city_data2017_element.js";
import _ from "lodash";
getorders;
export default {
  data() {
    return {
      WuLiu: WuLiu,
      rules: {
        address: [
          {
            required: true,
            message: "请填写详细地址",
            trigger: "blur"
          }
        ]
      },
      cityOptions: cityOptions,
      dialogWuliu: false,
      Editform: {
        address: ""
      },
      dialogVisible: false,
      total: 0,
      getOrderFn: {
        query: "",
        pagenum: 1,
        pagesize: 5
      },
      orderData: [],
      breadList: [
        {
          path: "/home",
          title: "首页"
        },
        {
          path: "",
          title: "商品管理"
        },
        {
          path: "/params",
          title: "参数列表"
        }
      ]
    };
  },
  created() {
    this.getorders();
  },
  methods: {
    handleEditArea(row) {
      console.log(row);
      this.dialogVisible = true;
      this.EditForm.area = row.area;
    },
    wuliuOk() {
      this.dialogWuliu = false;
    },
    handeate() {
      this.dialogWuliu = true;
    },
    Edit() {
      this.dialogVisible = true;
    },
    EditForm(row) {
      console.log(row);
    },
    async getorders() {
      let res = await getorders(this.getOrderFn);
      console.log(res);
      this.orderData = res.data.goods;
      this.total = res.data.total;
    },
    search: _.debounce(function() {
      this.getOrderFn.pagenum = 1;
      this.getorders();
    }, 2000),
    handleSizeChange(val) {
      this.getOrderFn.pagesize = val;
      this.getorders();
    },
    handleCurrentChange(val) {
      this.getOrderFn.pagenum = val;
      this.getorders();
    },
    handleChange(value) {
      console.log(value);
    }
  }
};
</script>

<style>
</style>
